#include <stdio.h>
int main()
{
    char *filename = "test2.txt";
    FILE *myfile = fopen(filename,"a+");
    if(myfile==NULL){
        printf("文件打开失败\r\n");
    }else{
        printf("文件打开成功\r\n");
    }

    char buffer[10];
    while (fgets(buffer,sizeof(buffer),myfile))
    {
        printf("%s",buffer);
    }
    
    int result = fclose(myfile);
    if(result!=0){
        printf("\n文件关闭失败%d\r\n",result);
    }else{
        printf("\n文件关闭成功%d\r\n",result);
    }
    return 0;

}